// components/LoginInput/LoginInput.js
import { http } from '../../utils/net.js'

Component({
  behaviors: ['wx://form-field'],
  properties: {
    label: String,
    iconPath: String,
    name: String,
    placeholder: String,
    value: String,
    type: {
      type: String,
      value: "text"
    },
    password: {
      type:Boolean,
      value: false
    },
    smsBtn: {
      type:Boolean,
      value: false
    },
    sendTel:String,
    smsClass:String
  },
  data: {
    smsBtnText: "获取验证码"
  },
  methods: {
    handleInputChange(event) {
      const { detail = {} } = event;
      const { value = '' } = detail;
      this.setData({ value });
      this.triggerEvent('change', event);
    },
    sendSms() {
      if(!this.properties.sendTel) {
        wx.showToast({
          title: '请先填写手机号',
          icon:"none"
        })
      } else {
        http({
          url: '/api/index/index?method=sendSms',
          data: {
            "tel": this.properties.sendTel,
            "class":this.properties.smsClass
          }
        })
      }
    }
  }
})
